home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 5.3 KB | 192 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWResAcc.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWRESACC_H
- #define FWRESACC_H
-
- #ifndef FWSTDDEF_H
- #include "FWStdDef.h"
- #endif
-
- #ifndef FWEXCDEF_H
- #include "FWExcDef.h"
- #endif
-
- #ifndef FWFILESP_H
- #include "FWFileSp.h"
- #endif
-
- #ifndef FWRESFI_K
- #include "FWResFil.k"
- #endif
-
- #ifndef FWRESFI_H
- #include "FWResFil.h"
- #endif
-
- #include "SLResour.xh"
-
- #if defined(FW_BUILD_WIN) && !defined(__WINDOWS_H)
- #include <windows.h>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__TYPES__)
- #include <Types.h>
- #endif
-
- //========================================================================================
- // CLASS FW_OResource
- //
- // This internal class is the reference counted representation class used by the
- // FW_CResource class defined below.
- //========================================================================================
-
-
- //========================================================================================
- // CLASS FW_CResource
- //========================================================================================
-
- class FW_PResource : public FW_TCountedSOMPtr<FW_OResource>
- {
- public:
- FW_DECLARE_AUTO(FW_PResource)
-
- public:
- ~FW_PResource();
- // Decrements the reference count.
- // Delete the resource access ref if count goes to zero.
-
- FW_PResource(Environment* ev,
- FW_OResourceFile* file,
- FW_ResourceID resourceID,
- FW_ResourceType resourceType);
- // Creates a new FW_CPrivResourceRep attached to the given resource.
-
- FW_PResource(const FW_PResource& other);
- FW_PResource& operator=(const FW_PResource& other);
-
- FW_PResource(Environment* ev, FW_OResource* rep);
- FW_PResource& operator=(FW_OResource* rep);
-
- };
-
- //----------------------------------------------------------------------------------------
- // FW_PResource::operator=
- //----------------------------------------------------------------------------------------
-
- inline FW_PResource& FW_PResource::operator=(const FW_PResource& other)
- {
- FW_TCountedSOMPtr<FW_OResource>::operator=(other);
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PResource::operator=
- //----------------------------------------------------------------------------------------
-
- inline FW_PResource& FW_PResource::operator=(FW_OResource* rep)
- {
- FW_TCountedSOMPtr<FW_OResource>::operator=(rep);
- return *this;
- }
-
-
- //========================================================================================
- // CLASS FW_CAcquireResourceData
- //========================================================================================
-
- class FW_CAcquireResourceData
- {
- public:
- FW_DECLARE_AUTO(FW_CAcquireResourceData)
-
- FW_CAcquireResourceData(Environment *ev, FW_OResource* resource);
- // Acquires the data using resource->AcquireData().
-
- ~FW_CAcquireResourceData();
- // Releases the data using resource->ReleaseData().
-
- void *GetData() const;
- // Returns a void* pointer to the data.
-
- unsigned long GetSize() const;
- // Returns the size of the resource, in bytes.
-
- private:
- FW_PResource fResource;
- // The resource.
-
- void* fData;
- // The acquired data.
-
- unsigned long fSize;
- // The size of the acquire data.
- };
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireResourceData::GetData
- //----------------------------------------------------------------------------------------
-
- inline void* FW_CAcquireResourceData::GetData() const
- {
- return fData;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireResourceData::GetSize
- //----------------------------------------------------------------------------------------
-
- inline unsigned long FW_CAcquireResourceData::GetSize() const
- {
- return fSize;
- }
-
- //========================================================================================
- // Global Utility Functions
- //========================================================================================
-
- // These functions will probably be moved into the Strings component.
- // To do so, we will make Strings be dependent on the Streams component,
- // and then provide "load string from sink" functions.
-
- FW_Boolean FW_HasStringByPosition(Environment *ev,
- FW_PResourceFile &file,
- FW_ResourceID resourceID,
- FW_ResourceType resourceType,
- unsigned short position);
-
- FW_Boolean FW_HasStringByID(Environment *ev,
- FW_PResourceFile &file,
- FW_ResourceID resourceID,
- FW_ResourceType resourceType,
- unsigned short id);
-
- void FW_LoadStringByPosition(Environment *ev,
- FW_PResourceFile &file,
- FW_ResourceID resourceID,
- FW_ResourceType resourceType,
- unsigned short position,
- FW_CString &string);
-
- void FW_LoadStringByID(Environment *ev,
- FW_PResourceFile &file,
- FW_ResourceID resourceID,
- FW_ResourceType resourceType,
- unsigned short id,
- FW_CString &string);
-
- FW_Boolean FW_LoadStringByIDNoFail(Environment *ev,
- FW_PResourceFile &file,
- FW_ResourceID resourceID,
- FW_ResourceType resourceType,
- unsigned short id,
- FW_CString &string);
-
- #endif
-